//$(document).ready(function() {
//$('#upload').click(function() {
//upload($('#imageFile').val());   //函数参数为上传的文件的本机地址
//});
//});

//function upload(fileName) {
//$.ajaxFileUpload({
//url : '/imageUpload?fileName='+fileName,   //提交的路径
//secureuri : false, // 是否启用安全提交，默认为false
//fileElementId : 'imageFile', // file控件id
//dataType : 'json',
//data : {
//fileName : fileName   //传递参数，用于解析出文件名
//}, // 键:值，传递文件名
//success : function(data, status) {
//if (data.error == 0) {
//var src = data.src;
//$('#show').append("<img src='" + src + "'>");  //显示图片

//// 存储已上传图片地址
//var oldSrc = $('#pictureSrc').val();
//var newSrc = "";
//if (oldSrc != "")
//newSrc = oldSrc + ";" + src;
//else
//newSrc = src;

//$('#pictureSrc').val(newSrc);   //保存路径
//} else {
//alert(data.message);
//}
//},
//error : function(data, status) {
//alert(data.message);
//}
//});
//}
$(document).ready(function() {
	$('#upload').click(function() {
		upload();   
	});
	$('#upload1').click(function() {
		upload1();   
	});
	$('#img').change(function () {  
        var str = $(this).val();  
        var fileName = getFileName(str);  
        var fileExt = str.substring(str.lastIndexOf('.') + 1); 
        img1 = str;
        alert(str);  
    });  
});
var img1 = ""
//获取文件名称  
function getFileName(path) {  
    var pos1 = path.lastIndexOf('/');  
    var pos2 = path.lastIndexOf('\\');  
    var pos = Math.max(pos1, pos2);  
    if (pos < 0) {  
        return path;  
    }  
    else {  
        return path.substring(pos + 1);  
    }  
} 
function upload() {
	var monPointId=$("#monPointId").val();
	var description=$("#description").val();
	var location=$("#location").val();
	console.log('http://127.0.0.1/front/form/doAdd2/pt_front_ob_zmsupply_qg2');
	$.ajaxFileUpload({
		url : 'http://127.0.0.1/front/form/doAdd2/pt_front_ob_zmsupply_qg2',   //提交的路径
		type: 'post',
		secureuri : false, // 是否启用安全提交，默认为false
		fileElementId : 'uploadfile', // file控件id
		dataType : 'json',
		data:{
		    "address": "磊地",
		    "city": 38,
		    "name": "刘海1",
		    "phone": "13468474449",
		    "province": 2,
		    "region": 400,
		    "userid": 66,
		    
		    "maintype":1,
		    "chtype":23,
		    
		    "typename":"xxx名称",
		    "num":15,
		    "specification":1,
		    "price":1.02,
		    "img1":"1.png",
		    "img2":"2.png",
		    "img3":"3.png",
		    "type":0
		}
,
		success : function(data, status) {
			console.log("aa");
			console.log(data);
			console.log(status);
		},
		error : function(data, status) {
			alert("上传失败");
		}
	});
}